<template>
  <div v-if="show" class="transition-container">
    <div class="cyber-grid">
      <div v-for="n in 100" :key="n" class="grid-item"></div>
    </div>
    <div class="loading-text">
      <span>系统接入中</span>
      <div class="progress-bar">
        <div class="progress"></div>
      </div>
    </div>
    <div class="cyber-circles">
      <div v-for="n in 3" :key="n" class="circle"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TransitionEffect',
  props: {
    show: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style scoped>
.transition-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #0a0a2a;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeOut 0.5s ease 2.5s forwards;
}

.cyber-grid {
  position: absolute;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 2px;
}

.grid-item {
  background: rgba(0, 255, 255, 0.1);
  animation: gridAnimation 0.5s ease forwards;
  opacity: 0;
  transform: scale(0);
}

.grid-item:nth-child(odd) {
  animation-delay: calc(0.02s * var(--i));
}

.loading-text {
  position: relative;
  z-index: 2;
  color: #00fff2;
  font-size: 2rem;
  text-align: center;
  text-shadow: 0 0 10px rgba(0, 255, 242, 0.5);
}

.progress-bar {
  width: 300px;
  height: 4px;
  background: rgba(0, 255, 242, 0.2);
  margin-top: 1rem;
  border-radius: 2px;
  overflow: hidden;
}

.progress {
  width: 100%;
  height: 100%;
  background: #00fff2;
  animation: progress 2s linear;
  transform-origin: left;
}

.cyber-circles {
  position: absolute;
  width: 100%;
  height: 100%;
}

.circle {
  position: absolute;
  border: 2px solid #00fff2;
  border-radius: 50%;
  opacity: 0;
  animation: circleAnimation 2s ease infinite;
}

.circle:nth-child(1) {
  width: 100px;
  height: 100px;
  animation-delay: 0s;
}

.circle:nth-child(2) {
  width: 200px;
  height: 200px;
  animation-delay: 0.5s;
}

.circle:nth-child(3) {
  width: 300px;
  height: 300px;
  animation-delay: 1s;
}

@keyframes gridAnimation {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes progress {
  0% {
    transform: scaleX(0);
  }
  100% {
    transform: scaleX(1);
  }
}

@keyframes circleAnimation {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  50% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.2);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    visibility: hidden;
  }
}

.grid-item {
  --i: 0;
}

@for $i from 1 through 100 {
  .grid-item:nth-child(#{$i}) {
    --i: #{$i};
  }
}
</style> 